﻿#ifndef TCPSOCKET_H
#define TCPSOCKET_H

#include <qtcpsocket.h>
#include <qtimer.h>

#include "TcpDataPreprocessor.h"
#include "LogSaver.h"

class TcpIOer :  public QTcpSocket
{
  Q_OBJECT
private:
  enum PrivateSignalClass
  {
    PrivateSignal
  };
private://property
  TcpDataPreprocessor tcpDataPreprocessor;
  QTimer* disconnectTimer=Q_NULLPTR;
private://dependency
  LogSaver* logSaver=LogSaver::getLogSaver();
public:
  explicit TcpIOer();
  virtual ~TcpIOer();
signals:
  void signal_dataReceived(QByteArray data,TcpIOer::PrivateSignalClass=TcpIOer::PrivateSignal);
  void signal_sendData(QByteArray data,TcpIOer::PrivateSignalClass=TcpIOer::PrivateSignal);
  void signal_lastWish(TcpIOer::PrivateSignalClass=TcpIOer::PrivateSignal);
  void signal_setCountDown(int msec);
public:
  void sendData(QByteArray data);
  void setCountDown(int msec);
private slots:
  void slot_sendData(QByteArray data);
private slots:
  void slot_readData();
  void slot_temp(QByteArray data);
};

#endif // TCPSOCKET_H
